Use images, css and js in the view file

  • Steps

    1. Images

    Create new folder named images in public folder. Copy images need to use in project to images folder.

    2. CSS

    Create new folder named css in public folder. In this folder, create new css file named style.css

    3. JS

    Create new folder named js in public folder. In this folder, create new javascript file named app.js

    4. Use the images, css and js in view

    1. Normal html page

    
            <html>
    
                <head>
                   
                    <title>Laravel</title>
                    <link href="public/css/style.css" rel="stylesheet" type="text/css">
                    
                </head>
    
                <body>
    
                    <h3 class="format-text">Demo Page</h3>
                    <img src="public/images/thumb1.gif" onclick="clickMe()">
    
                </body>
                <script src="public/js/app.js" type="text/javascript"></script>
           </html>
    
                
    The function asset() is used for linking the image/css/js

    
             <html>
    
                <head>
                   
                    <title>Laravel</title>
                    <link href="{{asset('public/css/style.css')}}" rel="stylesheet" type="text/css">
                   
                </head>
    
                <body>
    
                    <h3 class="format-text">Demo Page</h3>
                    <img src="{{asset('public/images/thumb1.gif')}}" onclick="clickMe()">
    
                </body>
                
                <script src="{{asset('public/js/app.js')}}" type="text/javascript"></script>
    
             </html>